package org.nstack.header.vm;

import org.nstack.header.message.APIDeleteMessage;
import org.nstack.header.message.APIEvent;
import org.nstack.header.message.APIMessage;
import org.nstack.header.message.APIParam;
import org.nstack.header.rest.RestRequest;
import org.springframework.http.HttpMethod;
import org.nstack.header.identity.Action;
import org.nstack.header.notification.ApiNotification;


@Action(category = VmInstanceConstant.ACTION_CATEGORY)
@RestRequest(
        path = "/vm-instances/{uuid}",
        method = HttpMethod.DELETE,
        responseClass = APIDestroyVmInstanceEvent.class
)
public class APIDestroyVmInstanceMsg extends APIDeleteMessage implements VmInstanceMessage {

    @APIParam(checkAccount = true, operationTarget = true)
    private String uuid;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    @Override
    public String getVmInstanceUuid() {
        return getUuid();
    }

 
    public static APIDestroyVmInstanceMsg __example__() {
        APIDestroyVmInstanceMsg msg = new APIDestroyVmInstanceMsg();
        msg.setUuid(uuid());
        return msg;
    }

    public ApiNotification __notification__() {
        APIMessage that = this;
        return new ApiNotification() {
            @Override
            public void after(APIEvent evt) {
                ntfy("Destroyed").resource(uuid, VmInstanceVO.class.getSimpleName())
                        .messageAndEvent(that, evt).done();
            }
        };
    }
}
